package com.ldc.wandroid.viewmodel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.ldc.common.model.BaseModel;
import com.ldc.common.mvvm.ViewModelBase;
import com.ldc.common.net.Api2Request;
import com.ldc.wandroid.model.WeChatNumberHistoryModel;
import com.ldc.wandroid.server.ApiServer;

public class WeChatNumberHistoryViewModel extends ViewModelBase {

    private final ApiServer apiServer;
    private final MutableLiveData<BaseModel<WeChatNumberHistoryModel>> wechatNumber = new MutableLiveData<>();
    private final MutableLiveData<BaseModel<Object>> collect = new MutableLiveData<>();


    public LiveData<BaseModel<WeChatNumberHistoryModel>> getWeChatNumber() {
        return wechatNumber;
    }

    public LiveData<BaseModel<Object>> getCollect() {
        return collect;
    }

    public WeChatNumberHistoryViewModel() {
        apiServer = Api2Request.getInstance().createServer(ApiServer.class);
    }


    public void getWechatNumberHiostoryReq(String wechar_id, int p) {
        apiRequest(apiServer.getWechatNumberHostory(wechar_id, p), (status, result, throwable) -> {
            if (status) {
                wechatNumber.setValue(result);
            } else {
                wechatNumber.setValue(null);
            }
        });

    }

    public void selectCollectReq(String id) {
        apiRequest(apiServer.selectCollect(id), (status, result, throwable) -> {
            if (status) {
                collect.setValue(result);
            } else {
                collect.setValue(null);
            }
        });
    }

    public void unSelectCollectOriginIdReq(String id) {

    }
}
